package cn.org.timespace.easyframe.action;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpSession;

import org.apache.log4j.Logger;


/**
 * <p>
 * 退出类
 * </p>
 * 
 * @version 1.0, 11/01/18
 * @since 1.0
 * @author 
 */

public class EfLogoffAction extends EFBaseAction {

	private static final long serialVersionUID = 7412511289827192017L;
	
	private static final String RELOGON = "reLogon";

	private static Logger log = Logger.getLogger(EfLogoffAction.class);

	public String execute() throws Exception {
		
		EfUserSession efUserSession =  getEfUserSession();
		if(efUserSession != null)
		{
			if(log.isInfoEnabled()) log.info("用户"+efUserSession.getEfUser().getUserAccount()+"正在退出系统...");
						
			HttpSession session = getRequest().getSession();
			session.setAttribute(SESSION_KEY, null);
			session.invalidate();
			
			if(log.isInfoEnabled()) log.info("用户"+efUserSession.getEfUser().getUserAccount()+"退出系统成功...");
		}
		else
		{
			if(log.isInfoEnabled()) log.info("在Session没有找到与用户相关的信息，直接退出系统...");
		}
		
		
		return RELOGON;
	}
}
